<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>

<html class="app-ui">

<head>
    <!-- Meta -->
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />

    <!-- Document title -->
    <title>已完成订单</title>

    <meta name="description" content="AppUI - Admin Dashboard Template & UI Framework" />
    <meta name="author" content="rustheme" />
    <meta name="robots" content="noindex, nofollow" />

    <!-- Favicons -->
    <link rel="apple-touch-icon" href="${pageContext.request.contextPath}/assets/img/favicons/apple-touch-icon.png" />
    <link rel="icon" href="${pageContext.request.contextPath}/assets/img/favicons/favicon.ico" />

    <!-- Google fonts -->
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:300,400,400italic,500,900%7CRoboto+Slab:300,400%7CRoboto+Mono:400" />

    <!-- AppUI CSS stylesheets -->
    <link rel="stylesheet" id="css-font-awesome" href="${pageContext.request.contextPath}/assets/css/font-awesome.css" />
    <link rel="stylesheet" id="css-ionicons" href="${pageContext.request.contextPath}/assets/css/ionicons.css" />
    <link rel="stylesheet" id="css-bootstrap" href="${pageContext.request.contextPath}/assets/css/bootstrap.css" />
    <link rel="stylesheet" id="css-app" href="${pageContext.request.contextPath}/assets/css/app.css" />
    <link rel="stylesheet" id="css-app-custom" href="${pageContext.request.contextPath}/assets/css/app-custom.css" />
    <!-- End Stylesheets -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/js/layui/css/layui.css" media="all">
</head>

<body class="app-ui layout-has-drawer layout-has-fixed-header">
<div class="app-layout-canvas">
    <div class="app-layout-container">

        <!-- Drawer -->
        <aside class="app-layout-drawer">

            <!-- Drawer scroll area -->
            <div class="app-layout-drawer-scroll" style="margin-top: 50px;">
                <!-- Drawer logo -->
                <div id="logo" class="drawer-header" style="text-align: center;margin: 0 auto;font-family: 华文楷体; padding-top: 20px;">
                    <span style="font-size: 34px;"><strong>商家后台</strong></span>
                </div>

                <!-- Drawer navigation -->
                <nav class="drawer-main">
                    <ul class="nav nav-drawer">
                        <li class="nav-item nav-drawer-header">
                            <hr color="#ccc">
                        </li>
                        <li class="nav-item">
                            <a href="UnFinishOrder.jsp"><i class="ion-ios-speedometer-outline"></i><span> 未完成订单</span></a>
                        </li>
                        <li class="nav-item">
                            <a href="FinishOrder.jsp"><i class="ion-ios-monitor-outline"></i><span style="font-size: 20px;"> 已完成订单</span></a>
                        </li>
                        <li class="nav-item">
                            <a href="goodsManager.jsp"><i class="ion-ios-monitor-outline"></i> 商品管理</a>
                        </li>
                        <li class="nav-item">
                            <a href="goodsIn.jsp"><i class="ion-ios-monitor-outline"></i> 进货记录</a>
                        </li>
                        <li class="nav-item">
                            <a href="goodsReturn.jsp"><i class="ion-ios-monitor-outline"></i> 退货记录</a>
                        </li>
                    </ul>
                </nav>
                <!-- End drawer navigation -->
            </div>
            <!-- End drawer scroll area -->
        </aside>
        <!-- End drawer -->

        <!-- Header -->
        <header class="app-layout-header">
            <nav class="navbar navbar-default">
                <div class="container">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#header-navbar-collapse"
                                aria-expanded="false">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <button class="pull-left hidden-lg hidden-md navbar-toggle" type="button" data-toggle="layout" data-action="sidebar_toggle">
                            <span class="sr-only">Toggle drawer</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <a class="navbar-brand" href="javascript:void(0)">
                            <img class="img-responsive" src="${pageContext.request.contextPath}/assets/img/logo/logo-frontend.png" title="强强组合商城" alt="AppUI" />
                        </a>
                    </div>

                    <div class="collapse navbar-collapse" id="header-navbar-collapse">
                        <!-- .navbar-left -->

                        <ul class="nav navbar-nav navbar-right navbar-toolbar hidden-sm hidden-xs">
                            <li class="active">
                                <a href="../home/frontend_home.jsp">商城首页</a>
                            </li>
                            <li class="active">
                                <a href="frontend_home.html"></a>
                            </li>
                            <li class="dropdown">
                                <a href="javascript:void(0)" data-toggle="dropdown"><i class="ion-ios-bell"></i> <span class="badge" style="background-color: red;">3</span></a>
                                <ul class="dropdown-menu dropdown-menu-right">
                                    <li>
                                        <a tabindex="-1" href="javascript:void(0)"><span class="badge pull-right" style="background-color: red;">2</span> 消息 </a>
                                    </li>
                                    <li>
                                        <a tabindex="-1" href="javascript:void(0)"><span class="badge pull-right" style="background-color: red;">1</span> 通知 </a>
                                    </li>

                                </ul>
                            </li>

                            <li class="dropdown dropdown-profile">
                                <a href="javascript:void(0)" data-toggle="dropdown">
                                    <span class="m-r-sm">${account.accName} <span class="caret"></span></span>
                                    <img class="img-avatar img-avatar-48" src="${pageContext.request.contextPath}/file/acc/${account.accImg == null?"000000011612245316757212.png":account.accImg}" alt="User profile pic" />
                                </a>
                                <ul class="dropdown-menu dropdown-menu-right">
                                    <li>
                                        <a href="../MyAccount/myInformation.jsp">个人账户</a>
                                    </li>
                                    <li>
                                        <a href="#" id="logout">退出</a>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                        <!-- .navbar-right -->
                    </div>
                </div>
                <!-- .container-fluid -->
            </nav>
            <!-- .navbar-default -->
        </header>
        <!-- End header -->

        <main class="app-layout-content">

            <!-- Page Content -->
            <div class="container-fluid p-y-md">
                <!-- Cards API, functionality initialized in App() -> uiCardsApi() -->
                <div class="row">

                    <div class="col-sm-12">
                        <div class="card">
                            <div class="card-block">
                                <div class="text-center" style="font-size: 24px; text-align: center;margin: 0 auto;font-family: 华文楷体;">
                                    <label style="float: left;font-size: 25px;">订单查询：</label>
                                    <div style="float: left;">
                                        <!-- 起始日期 -->
                                      起始日期：  <input id="startDate" style="height: 30px;"  type="date" />
                                    </div>
                                    <div class="mui-input-row mui-checkbox mui-left" style="float: left;">
                                        &nbsp;&nbsp;
                                        <input id="received" type="checkbox"  style="width: 17px; height: 17px;" >
                                        <label>已签收</label>
                                        &nbsp;&nbsp;&nbsp;
                                    </div>
                                    <div class="mui-input-row mui-checkbox mui-left" style="float: left;">
                                        <input id="returned" type="checkbox"  style="width: 17px; height: 17px;" >
                                        <label>已退款</label>
                                    </div>
                                </div>

                                <form class="form-horizontal m-t-sm text-center row" action="base_forms_pickers_select.html" method="post"
                                      onsubmit="return false;">
                                    <div class="form-group col-md-8" style="left: 200px;">

                                    </div>
                                </form>

                                <div class="table-responsive">
                                    <table class="layui-hide" id="demo" lay-filter="test"></table>

                                </div>
                                <!-- .table-responsive -->
                            </div>
                        </div>
                    </div>
                    <!-- .col-sm-12 -->
                </div></div>
                <!-- .row -->
        </main>

    </div>
    <!-- .app-layout-container -->
</div>
<!-- .app-layout-canvas -->

<!-- AppUI Core JS: jQuery, Bootstrap, slimScroll, scrollLock and App.js -->
<!-- AppUI Core JS: jQuery, Bootstrap, slimScroll, scrollLock and App.js -->
<script src="${pageContext.request.contextPath}/assets/js/core/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/core/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/core/jquery.slimscroll.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/core/jquery.scrollLock.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/core/jquery.placeholder.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/app-custom.js"></script>

<!-- Page JS Plugins -->
<script src="${pageContext.request.contextPath}/assets/js/plugins/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/bootstrap-colorpicker/bootstrap-colorpicker.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/select2/select2.full.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/masked-inputs/jquery.maskedinput.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/dropzonejs/dropzone.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/plugins/jquery-tags-input/jquery.tagsinput.min.js"></script>
<div class="app-ui-mask-modal"></div>

<script src="${pageContext.request.contextPath}/js/My97DatePicker/WdatePicker.js"></script>
<script src="${pageContext.request.contextPath}/js/layui/layui.js"></script>

<script type="text/javascript">
    $(function() {
        //商家id
        var accId = ${account.accId};
        var ordStatus = "";

        getFirstDayOfMonth();
        //得到每月的第一天日期
        function getFirstDayOfMonth(){
            var date = new Date();
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            if(month < 10){
                $("#startDate").val(year+"-"+"0"+month+"-"+"01");
            }else{
                $("#startDate").val(year+"-"+month+"-"+"01");
            }
        }
        var startDate = $("#startDate").val();

        layui.use(['laydate', 'table', 'carousel', 'upload'], function(){
            var laydate = layui.laydate //日期
                ,table = layui.table //表格
                ,carousel = layui.carousel //轮播
                ,upload = layui.upload //上传

            showTable();
            function showTable(){
                //执行一个 table 实例
                table.render({
                    elem: '#demo'
                    //    ,height: 500
                    ,url: "/business/selectFinishOrder?accId="+accId+"&startDate="+startDate+"&ordStatus="+ordStatus+"" //数据接口
                    ,title: '用户表'
                    ,page: true //开启分页
                    ,cols: [[ //表头
                        {field: 'numbers', title: '序号', width:80, type: 'numbers'}
                        ,{field: 'detId', title: '订单详细id', width:120, sort: true, hide:true}
                        ,{field: 'goNm', title: '商品名称', width:100}
                        ,{field: 'goPri', title: '商品价格', width:100}
                        ,{field: 'goNum', title: '订单数量', width: 100, totalRow: true}
                        ,{field: 'totalPrice', title: '订单总额', width:100, }
                        ,{field: 'receTime', title: '完成时间', width:160, sort: true}
                        ,{field: 'ordStatus', title: '订单状态', width:150, templet: function(d){
                                if(d.ordStatus == 5)
                                {return '<span style="color:#0000FF;">' + '已签收' + '</span>'}
                                else
                                {return '<span style="color:red;">' + '已退款' + '</span>'}
                            }}
                    ]]
                    ,limits: [3,5,10]
                    ,limit: 5 //每页默认显示的数量
                });

            }

            /*根据起始日期查询*/
            $("#startDate").change(function (){
                startDate = $(this).val();
                showTable();
            })

            /*查询已签收*/
            $("#received").click(function (){
                //点击已签收复选框，取消选中已退款复选框
                $("#returned").prop("checked", false);   //checked 属于特殊属性，使用 prop函数
                if($(this).prop("checked") == true){    //当已签收复选框 被选中，查已签收订单
                    startDate = $("#startDate").val();
                    ordStatus = 5;
                    showTable();
                }else {                                 //当已签收复选框 取消选中，查所有订单
                    ordStatus = "";
                    showTable();
                }

            })

            /*查询已退款*/
            $("#returned").click(function (){
                //点击已退款复选框，取消选中已签收复选框
                $("#received").prop("checked", false);
                if($(this).prop("checked") == true){        //当已退款复选框 被选中，查已退款订单
                    startDate = $("#startDate").val();
                    ordStatus = 9;
                    showTable();
                }else {                                     //当已退款复选框 取消选中，查所有订单
                    ordStatus = "";
                    showTable();
                }
            })
        });

        /*退出登录*/
        $("#logout").click(function (event){
            event.preventDefault();
            var url = "/login/logoutShop";
            $.post(url,function (){
                window.location.href = "../../login.jsp";
            })
        })


    });
</script>

</body>

</html>
